package controllers.administrator;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import services.CustomerService;

import controllers.AbstractController;
import domain.Customer;

@Controller
@RequestMapping("/customer/administrator")
public class CustomerAdministratorController extends AbstractController{

	//Services
		@Autowired
		private CustomerService customerService;
		
		// Constructors

		public CustomerAdministratorController() {
			super();
		}

		// Listing methods
		@RequestMapping(value = "/list", method = RequestMethod.GET)
		public ModelAndView list() {
			ModelAndView result;
			Collection<Customer> customers;

			customers = customerService.findAll();

			result = new ModelAndView("customer/list");
			result.addObject("requestURI", "customer/administrator/list.do");
			result.addObject("customers", customers);
			result.addObject("backURI", "/welcome/index.do");
			return result;
		}
}
